#ifndef ERDIAGRAMVIEW_H
#define ERDIAGRAMVIEW_H

#include <QWidget>
#include <QMap>
#include <QSqlDatabase>
#include <QGraphicsView>
#include <QGraphicsScene>

class ERDiagramView : public QGraphicsView
{
    Q_OBJECT

public:
    explicit ERDiagramView(QWidget *parent = nullptr);
    
    void setDatabase(const QSqlDatabase &db);
    void refreshDiagram();
    
private slots:
    void zoomIn();
    void zoomOut();
    void zoomReset();
    
private:
    void setupUI();
    void loadDatabaseSchema();
    void clearDiagram();
    
    QSqlDatabase m_database;
    QGraphicsScene *m_scene;
    
    // 缩放相关
    qreal m_currentScale;
    static constexpr qreal MIN_SCALE = 0.1;
    static constexpr qreal MAX_SCALE = 5.0;
    static constexpr qreal SCALE_FACTOR = 1.2;
};

#endif // ERDIAGRAMVIEW_H